home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
cditp21.zip
/
CODEIT.E_
/
DEMOMW.BAS
< prev
next >
Wrap
BASIC Source File
|
1992-05-27
|
13KB
|
436 lines
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'
'This module demonstrates how to use the windows from CIWIND1.LIB with the
'pull down menus from CIMENU1.LIB in version 2.1 & up of the CODE-IT toolbox.
'The main improvement in this version is the ability to call the pull down
'menus directly from a data window with either the ALT keypress or a mouse
'click on the pull down menu bar(row 1, column 1 to 80).
'
'The program starts by defining the menus and windows. Then turns on the
'pull down menu bar making it visable to the user. Control of the program
'is then passed to the WindowControl SUB which determins which window to
'go to.
'
'Once in a window, the user can type in data or at any time call the pull
'down menus. Pressing escape from the menu returns the user to the field
'where they came from. Selecting another window other than the one they are
'in sets the WhichWindow variable switch and causes an exit from the
'current window back to the WindowControl SUB and on to the next window.
'
'Enjoy,
'
' Clear Software
'
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DECLARE SUB InvoiceWindow ()
DECLARE SUB MenuControl ()
DECLARE SUB NameAddrsWindow ()
DECLARE SUB WindowControl ()
DECLARE SUB DemoMenuInit ()
DECLARE SUB DemoWindowInit ()
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'DEMOMW.BAS Copyright (C) 1991-1992, Clear Software. ALL RIGHTS RESERVED.
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'$INCLUDE: 'CITOOLS.BI'
'$INCLUDE: 'CIMOUSE.BI'
'$INCLUDE: 'CIMENU1.BI'
'$INCLUDE: 'CIWIND1.BI'
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DEFINT A-Z
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CONST TRUE = -1, FALSE = 0
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
TYPE MiscData
names AS STRING * 35
address AS STRING * 35
city AS STRING * 20
state AS STRING * 2
zip AS STRING * 5
product AS STRING * 35
price AS STRING * 10
END TYPE
DIM SHARED dat AS MiscData
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DIM SHARED DONEFLAG 'TRUE if exit was chosen from the menu
DIM SHARED WhichWindow 'Control switch for window swaping
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'-------Initialize the data type with null strings.
dat.names = ""
dat.address = ""
dat.city = ""
dat.state = ""
dat.zip = ""
dat.product = ""
dat.price = ""
'-------Initialize the mouse and make sure it's off when we paint the screen.
MouseInit
MouseHide
CLS
COLOR 3, 0
ScreenPaint 2, 79, 3, 21, "▒"
DrawBox 1, 80, 2, 22, 1
'-------Initialize and run the program
DemoMenuInit
DemoWindowInit
PullDownTitleOn
MouseShow
WindowControl
'-------Turn the couse off and restore the screen before exiting.
MouseHide
COLOR 7, 0
CLS
END
SUB DemoMenuInit
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'Initialize the demo pull down menus.
'
'Dimention the arrays for the pull down menu descriptions. Notice the
'dimentions are (1 TO 20).
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DIM pdmw1$(1 TO 20)
DIM pdmw2$(1 TO 20)
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'Set the menu definitions.
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
PullDownDefine 1, 0, 1, "Window", 1
PullDownDefine 1, 1, 1, "Make Name/Address Window Active", 6
PullDownDefine 1, 2, 1, "Make Invoice Window Active", 6
PullDownDefine 2, 0, 1, "Quit", 1
PullDownDefine 2, 1, 1, "Exit", 2
PullDownColors 0, 7, 0, 7, 0, 7, 14, 0, 8, 7, 11, 15
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'Set the area, colors and contents for the menu descriptions.
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
PullDownTitleDescript "<Enter=Accept> <Arrow=Next Title> <Escape=Exit>"
PullDownDescriptArea 23, 2, 78, 11, 0
pdmw1$(1) = " Type information into the Name/Address window"
pdmw1$(2) = " Enter a customer invoice"
PullDownDescript 1, pdmw1$()
pdmw2$(1) = " Exit this nifty demonstration program!"
PullDownDescript 2, pdmw2$()
END SUB
SUB DemoWindowInit
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'Initialize the demo windows.
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'------Window 1
WindowDefine 1, 9, 71, 6, 10, "NAMES AND ADDRESSES", 1, 2
'------Window 2
WindowDefine 2, 15, 65, 6, 10, "INVOICE", 1, 2
'Turn on the pull down menu detection for the windows
WindowToPull 1
END SUB
SUB InvoiceWindow
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'Define the colors and edit fields.
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WindowColors 7, 1, 7, 1, 15, 1, 1, 3
WindowOn 2
WindowPrint 2, 2, 2, "NAME : " + RTRIM$(dat.names), 1
EditFieldColors 0, 3
EditFieldDefine 2, 1, RTRIM$(dat.product), 3, 2, 36, 35, "PRODUCT: ", 1
EditFieldDefine 2, 2, RTRIM$(dat.price), 4, 2, 11, 10, "PRICE $:", 4
'===========================================================================
'Show the mouse, set the cursor in the first field and make the widow active
'===========================================================================
MouseShow
item = 1
DO
IF WhichWindow = 1 THEN EXIT DO
IF DONEFLAG THEN EXIT DO
IF item > 2 THEN item = 1
IF item < 1 THEN item = 2
WindowActive item
SELECT CASE WindowEvent(0) 'Find out what took place.
CASE 1 'A mouse event took place
SELECT CASE WindowEvent(1) 'Which field was selected
CASE 100 'The mouse was clicked on
PullDownActive 'the pull down menu bar
MenuControl
CASE ELSE
item = WindowEvent(1)
END SELECT
CASE 2 'A key was pressed
SELECT CASE WindowEvent(2) 'Which field are we on
CASE 1, 3, 6 'Enter, Tab, or Down arrow
item = item + 1
CASE 4 'Shift Tab or Up arrow
item = item - 1
CASE 100 'Alt Key
PullDownActive
MenuControl
CASE ELSE
BEEP
END SELECT
END SELECT
LOOP
'===========================================================================
'Assign the variables to the type structure, turn off the mouse and close
'the window.
'===========================================================================
GOSUB AssignInvoices
MouseHide
WindowOff 2
EXIT SUB
':::::::::::::::::::::::::::: Routines
AssignInvoices:
dat.product = EditFieldGet(1)
dat.price = EditFieldGet(2)
RETURN
END SUB
SUB MenuControl
'===========================================================================
'
'This routine figures program flow depending on the selection from the pull
'down menu. Notice that there is no loop in this sub. It only determines
'if a selection was made, then sets the variable switches to reflect it.
'
'Called from the window loops in NameAddrsWindow and InvoiceWindow.
'
'===========================================================================
menu = PullDownInfo(1)
item = PullDownInfo(2)
SELECT CASE menu
CASE 1 'The first menu was chosen.
SELECT CASE item
CASE 1
WhichWindow = 1
CASE 2
WhichWindow = 2
END SELECT
CASE 2 'The second menu was chosen.
SELECT CASE item
CASE 1
DONEFLAG = TRUE
END SELECT
END SELECT
END SUB
SUB NameAddrsWindow
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'Define the colors and edit fields.
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
WindowColors 0, 7, 0, 7, 15, 1, 1, 3
WindowOn 1
EditFieldColors 0, 3
EditFieldDefine 1, 1, RTRIM$(dat.names), 2, 3, 36, 35, "NAME :", 1
EditFieldDefine 1, 2, RTRIM$(dat.address), 3, 3, 36, 35, "ADDRESS:", 1
EditFieldDefine 1, 3, RTRIM$(dat.city), 4, 3, 21, 20, "CITY :", 1
EditFieldDefine 1, 4, RTRIM$(dat.state), 4, 34, 3, 2, "STATE :", 20
EditFieldDefine 1, 5, RTRIM$(dat.zip), 4, 47, 6, 5, "CITY :", 3
'===========================================================================
'Show the mouse, set the cursor in the first field and make the widow active
'===========================================================================
item = 1
MouseShow
DO
IF WhichWindow = 2 THEN EXIT DO
IF DONEFLAG THEN EXIT DO
IF item > 5 THEN item = 1
IF item < 1 THEN item = 5
WindowActive item
SELECT CASE WindowEvent(0) 'Find out what took place.
CASE 1 'A mouse event took place
SELECT CASE WindowEvent(1) 'Which field was selected
CASE 100 'The mouse was clicked on
PullDownActive 'the pull down menu bar
MenuControl
CASE ELSE
item = WindowEvent(1)
END SELECT
CASE 2 'A key was pressed
SELECT CASE WindowEvent(2) 'Which field are we on
CASE 1, 3, 6 'Enter, Tab, or Down arrow
item = item + 1
CASE 4 'Shift Tab or Up arrow
item = item - 1
CASE 100 'Alt Key
PullDownActive
MenuControl
CASE ELSE
BEEP
END SELECT
END SELECT
LOOP
'===========================================================================
'Assign the variables to the type structure, turn off the mouse and close
'the window.
'===========================================================================
GOSUB AssignData
MouseHide
WindowOff 1
EXIT SUB
':::::::::::::::::::::::::::: Routines
AssignData:
dat.names = EditFieldGet(1)
dat.address = EditFieldGet(2)
dat.city = EditFieldGet(3)
dat.state = EditFieldGet(4)
dat.zip = EditFieldGet(5)
RETURN
END SUB
SUB WindowControl
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'
'This SUB controls the program flow (which window to go to). By using this
'format of program control, the stack space is kept as clean as possible
'giving you the most memory for your procedure calls.
'
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DONEFLAG = FLASE
DO
SELECT CASE WhichWindow
CASE 1
CALL NameAddrsWindow
CASE 2
CALL InvoiceWindow
CASE ELSE
WhichWindow = 1
END SELECT
LOOP WHILE NOT DONEFLAG
END SUB